<?php
$PageTitle = 'Profile';
include('includes/header.php');
if(isset($_COOKIE['identifier']))
{
	$identifier = $_COOKIE['identifier'];
}
else
{
	$identifier = "";
	ob_start();
	header( 'Location: login.php');
}

$link = mysql_connect('localhost', 'root', '');
if(!$link)
{
	die('Not connected : ' . mysql_error());
}
$db = mysql_select_db('games');
if(!$db)
{
	die('No db : ' . mysql_error());
}

$query = "SELECT * FROM users where Identifier = '".$identifier."'";

$result = mysql_query($query);
if(!$result)
{
	die('Query error : ' . mysql_error());
}
if(mysql_num_rows($result) == 0)
{
	ob_start();
	header( 'Location: create-user.php');
}

while($row = mysql_fetch_assoc($result))
{
$firstname = $row['FirstName'];
$lastname = $row['LastName'];
$email = $row['Email'];
$username = $row['UserName'];
}


?>
<table>
<tr><td colspan="2"><b style="font-size:200%">User Profile</b><a href="profile.php?mode=edit">edit</a></td></tr>
<tr><th>First name:</th><td><?php echo $firstname ?></td></tr>
<tr><th>Last name:</th><td><?php echo $lastname ?></td></tr>
<tr><th>Email:</th><td><?php echo $email ?></td></tr>
<tr><th>Username:</th><td><?php echo $username ?></td></tr>
</table>


<div id="delete">
	<div>
		<h3><a href="#">Delete Profile</a></h3>
		<div>
			<form name="deleteprofile" method="post" action="drop-user.php">
			Are you sure you want to delete your profile? <br>
			Type the email associated with your account here to confirm: <input type="text" name="email">
			<input type="button" onclick="document.deleteprofile.submit();" value="Yes, Delete">
			</form>
		</div>
	</div>
</div>
<?php include('includes/footer.html') ?>
</body>
</html>

